/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DanielCardLayout.java
 *
 * Created on 15/02/2010, 15:55:08
 */
package br.com.sofp.Teste;

import java.awt.CardLayout;

/**
 *
 * @author Daniel
 */
public class DanielCardLayout extends javax.swing.JFrame {

    /** Creates new form DanielCardLayout */
    public DanielCardLayout() {
        initComponents();
    }

    private void mostrarTela(String nome) {
        CardLayout card = (CardLayout) jpPrincipal.getLayout();
        card.show(jpPrincipal, nome);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jbTela1 = new javax.swing.JButton();
        jbTela2 = new javax.swing.JButton();
        jbTela3 = new javax.swing.JButton();
        jpPrincipal = new javax.swing.JPanel();
        jpTela1 = new javax.swing.JPanel();
        jpTela2 = new javax.swing.JPanel();
        jpTela3 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jbTela1.setText("Tela 1");
        jbTela1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbTela1ActionPerformed(evt);
            }
        });

        jbTela2.setText("Tela 2");
        jbTela2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbTela2ActionPerformed(evt);
            }
        });

        jbTela3.setText("Tela 3");
        jbTela3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbTela3ActionPerformed(evt);
            }
        });

        jpPrincipal.setLayout(new java.awt.CardLayout());

        jpTela1.setBackground(new java.awt.Color(204, 204, 255));

        javax.swing.GroupLayout jpTela1Layout = new javax.swing.GroupLayout(jpTela1);
        jpTela1.setLayout(jpTela1Layout);
        jpTela1Layout.setHorizontalGroup(
            jpTela1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 526, Short.MAX_VALUE)
        );
        jpTela1Layout.setVerticalGroup(
            jpTela1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 341, Short.MAX_VALUE)
        );

        jpPrincipal.add(jpTela1, "card1");

        jpTela2.setBackground(new java.awt.Color(255, 255, 204));

        javax.swing.GroupLayout jpTela2Layout = new javax.swing.GroupLayout(jpTela2);
        jpTela2.setLayout(jpTela2Layout);
        jpTela2Layout.setHorizontalGroup(
            jpTela2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 526, Short.MAX_VALUE)
        );
        jpTela2Layout.setVerticalGroup(
            jpTela2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 341, Short.MAX_VALUE)
        );

        jpPrincipal.add(jpTela2, "card2");

        jpTela3.setBackground(new java.awt.Color(51, 255, 102));

        javax.swing.GroupLayout jpTela3Layout = new javax.swing.GroupLayout(jpTela3);
        jpTela3.setLayout(jpTela3Layout);
        jpTela3Layout.setHorizontalGroup(
            jpTela3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 526, Short.MAX_VALUE)
        );
        jpTela3Layout.setVerticalGroup(
            jpTela3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 341, Short.MAX_VALUE)
        );

        jpPrincipal.add(jpTela3, "card3");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jpPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 526, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jbTela1)
                        .addGap(18, 18, 18)
                        .addComponent(jbTela2)
                        .addGap(18, 18, 18)
                        .addComponent(jbTela3)))
                .addContainerGap(26, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbTela1)
                    .addComponent(jbTela2)
                    .addComponent(jbTela3))
                .addGap(18, 18, 18)
                .addComponent(jpPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbTela1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbTela1ActionPerformed

        mostrarTela("card1");
    }//GEN-LAST:event_jbTela1ActionPerformed

    private void jbTela2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbTela2ActionPerformed
        mostrarTela("card2");
    }//GEN-LAST:event_jbTela2ActionPerformed

    private void jbTela3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbTela3ActionPerformed
        mostrarTela("card3");
    }//GEN-LAST:event_jbTela3ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new DanielCardLayout().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jbTela1;
    private javax.swing.JButton jbTela2;
    private javax.swing.JButton jbTela3;
    private javax.swing.JPanel jpPrincipal;
    private javax.swing.JPanel jpTela1;
    private javax.swing.JPanel jpTela2;
    private javax.swing.JPanel jpTela3;
    // End of variables declaration//GEN-END:variables
}
